import request from '@/utils/request'
import fileAPI from '@/utils/fileAPI'
export function list(data) {
  return request({
    url: '/sale/order/list',
    method: 'post',
    data: data
  })
}
export function saleOrderList(data) {
  return request({
    url: '/sale/order/listForPlanProductionNew',
    method: 'post',
    data: data
  })
}
export function listForDeliver(data) {
  return request({
    url: '/sale/order/listForDeliver',
    method: 'post',
    data: data
  })
}
export function listForReturn(data) {
  return request({
    url: '/sale/order/listForReturn',
    method: 'post',
    data: data
  })
}
export function listForReview(data) {
  return request({
    url: '/sale/order/listForReview',
    method: 'post',
    data: data
  })
}

export function addOrUpdate(data) {
  return request({
    url: '/sale/order/addOrEdit',
    method: 'post',
    data: data
  })
}
export function updateFile(data) {
  return request({
    url: '/sale/order/updateFile',
    method: 'post',
    data: data
  })
}
export function listAllOrderDetail(data) {
  return request({
    url: '/sale/order/listAllOrderDetail',
    method: 'post',
    data: data
  })
}

export function remove(data) {
  return request({
    url: '/sale/order/delete',
    method: 'post',
    data: { deleteIds: data }
  })
}
export function getSearchInfo(data) {
  return request({
    url: '/sale/order/getInfoForReturn/' + data,
    method: 'get'
  })
}
export function getInfo(data) {
  return request({
    url: '/sale/order/' + data,
    method: 'get'
  })
}
export function getInfoForReturn(data) {
  return request({
    url: '/sale/order/getInfoForReturn/' + data,
    method: 'get'
  })
}
export function getMarketInfo(data) {
  return request({
    url: '/sale/order/getInfoForDeliver/' + data,
    method: 'get'
  })
}
export function getcustMarketInfo(data) {
  return request({
    url: '/sale/order/getOrderDetailByCustomerId',
    method: 'post',
    data: data
  })
}
export function getcustMarketInfo2(data) {
  return request({
    url: '/sale/order/getOrderDetailByCustomerId',
    method: 'post',
    data: data
  })
}
export function getSaleDeliverInformation(data) {
  return request({
    url: '/sale/customer/getSaleDeliverInformation',
    method: 'post',
    data: data
  })
}
export function getMaterialType(data) {
  return request({
    url: '/wms/type/list',
    method: 'post',
    data: data
  })
}
export function getMaterial(data) {
  return request({
    url: '/wms/material/list',
    method: 'post',
    data: data
  })
}
export function listPriceByCustomer(data) {
  return request({
    url: '/sale/price/listPriceByCustomer',
    method: 'post',
    data: data
  })
}
export function getInfoForPlanProduct(data) {
  return request({
    url: '/sale/order/getInfoForPlanProduct/' + data,
    method: 'get'
  })
}
export function listForPlanProduction(data) {
  return request({
    url: '/sale/order/listForPlanProduction',
    method: 'post',
    data: data
  })
}
export function finishOrder(data) {
  return request({
    url: '/sale/order/finishOrder/' + data,
    method: 'get'
  })
}
export function listForSaleAndOut(data) {
  return request({
    url: '/wms/material/listForSaleAndOut',
    method: 'post',
    data: data
  })
}
export function review(data) {
  return request({
    url: '/sale/order/review',
    method: 'post',
    data: data
  })
}
export function orderapproval(data) {
  return request({
    url: '/sale/order/approval',
    method: 'post',
    data: data
  })
}
export function printExcel(data) {
  return request({
    url: '/system/print/record/search',
    method: 'post',
    data: data
  })
}
export function importMethod(files, onUploadProgress) {
  const formData = new FormData()
  for (let i = 0; i < files.length; i++) {
    formData.append('file', files[i], files[i].name)
  }
  return fileAPI({
    url: '/sale/order/detail/import',
    method: 'post',
    data: formData,
    onUploadProgress
  })
}
